#include "mycontrol.h"
#include "ui_mycontrol.h"

myControl::myControl(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::myControl)
{
    ui->setupUi(this);
    //设置数值范围
    ui->horizontalSlider->setRange(0,100);
    ui->spinBox->setRange(0,100);

    //建立两个控件的关联
    //滚动滚桥的时候，计数器跟着变化
    connect(ui->horizontalSlider,&QSlider::valueChanged,[=](int value){
        ui->spinBox->setValue(value);
    });
    //计数器数值变化，滚桥发生变化
    connect(ui->spinBox,static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
            ui->horizontalSlider,&QSlider::setValue);
}

myControl::~myControl()
{
    delete ui;
}
